
#import "UIView+xib.h"
#import "UIColor+category_CCKit.h"
#import "UIControl+xib.h"
@implementation UIView (xib)
@dynamic borderColor;
@dynamic borderWidth;
@dynamic cornerRadius;
@dynamic  borderHexColor;
@dynamic  backGroudHexColor;
- (void)setBorderWidth:(CGFloat)borderWidth
{
    if(borderWidth <0) return;
    self.layer.borderWidth = borderWidth;
    self.layer.masksToBounds = YES;
}
- (void)setBorderColor:(UIColor *)borderColor
{
    self.layer.borderColor = borderColor.CGColor;
    self.layer.masksToBounds = YES;
}
- (void)setCornerRadius:(CGFloat)cornerRadius
{
    if(cornerRadius <0) return;
    self.layer.cornerRadius = cornerRadius;
    self.layer.masksToBounds = YES;
}
- (void)setBorderHexColor:(NSString *)borderHexColor
{
    self.layer.borderColor = ColorHex(borderHexColor).CGColor;
}
- (void)setBackGroudHexColor:(NSString *)backGroudHexColor
{
    self.backgroundColor = ColorHex(backGroudHexColor);
}
+(UINib*)nib
{
    return  [UINib nibWithNibName:NSStringFromClass(self) bundle:nil];
}
+(NSString *)ID
{
    return [NSString stringWithFormat:@"%@ID",NSStringFromClass(self)];
}
+(id)loadFromXIB
{
    return [[[NSBundle mainBundle] loadNibNamed:NSStringFromClass([self class]) owner:nil options:nil] lastObject];
}
- (void)loadView
{
    UINib *nib = [UINib nibWithNibName:NSStringFromClass([self class]) bundle:nil];
    UIView *view = [nib instantiateWithOwner:self options:nil].lastObject;
    view.frame = self.bounds;
    [self addSubview:view];
}
-(NSLayoutConstraint *)a1:(NSLayoutAttribute )a1 e:(NSLayoutRelation)e t:(UIView*)view a2:(NSLayoutAttribute )a2 c:(CGFloat)c
{
    return [NSLayoutConstraint constraintWithItem:self attribute:a1 relatedBy:e toItem:view attribute:a2 multiplier:1 constant:c];
}
@end
